.class public Lrexsee/barcode/CaptureHandler;
.super Landroid/os/Handler;
.source "CaptureHandler.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lrexsee/barcode/CaptureHandler$State;
    }
.end annotation


# instance fields
.field private final decodeThread:Lrexsee/barcode/DecodeThread;

.field private final mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

.field private state:Lrexsee/barcode/CaptureHandler$State;


# direct methods
.method public constructor <init>(Lrexsee/barcode/BarcodeCaptureDialog;)V
    .locals 4
    .param p1, "dialog"    # Lrexsee/barcode/BarcodeCaptureDialog;

    .prologue
    const/4 v3, 0x1

    .line 20
    invoke-direct {p0}, Landroid/os/Handler;-><init>()V

    .line 21
    iput-object p1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    .line 22
    new-instance v1, Lrexsee/barcode/DecodeThread;

    iget-object v2, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    invoke-direct {v1, v2}, Lrexsee/barcode/DecodeThread;-><init>(Lrexsee/barcode/BarcodeCaptureDialog;)V

    iput-object v1, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    .line 24
    :try_start_0
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    invoke-virtual {v1}, Lrexsee/barcode/DecodeThread;->start()V

    .line 25
    sget-object v1, Lrexsee/barcode/CaptureHandler$State;->SUCCESS:Lrexsee/barcode/CaptureHandler$State;

    iput-object v1, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    .line 26
    iget-object v1, p1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    if-eqz v1, :cond_0

    iget-boolean v1, p1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewing:Z

    if-nez v1, :cond_0

    .line 27
    iget-object v1, p1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v1}, Landroid/hardware/Camera;->startPreview()V

    .line 28
    const/4 v1, 0x1

    iput-boolean v1, p1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewing:Z

    .line 30
    :cond_0
    invoke-direct {p0}, Lrexsee/barcode/CaptureHandler;->restartPreviewAndDecode()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 34
    :goto_0
    return-void

    .line 31
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 32
    .local v0, "e":Ljava/lang/Exception;
    invoke-virtual {p1}, Lrexsee/barcode/BarcodeCaptureDialog;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2, v3}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v1

    invoke-virtual {v1}, Landroid/widget/Toast;->show()V

    goto :goto_0
.end method

.method private restartPreviewAndDecode()V
    .locals 4

    .prologue
    .line 91
    :try_start_0
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    sget-object v2, Lrexsee/barcode/CaptureHandler$State;->SUCCESS:Lrexsee/barcode/CaptureHandler$State;

    if-ne v1, v2, :cond_0

    .line 92
    sget-object v1, Lrexsee/barcode/CaptureHandler$State;->PREVIEW:Lrexsee/barcode/CaptureHandler$State;

    iput-object v1, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    .line 93
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    iget-object v2, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    invoke-virtual {v2}, Lrexsee/barcode/DecodeThread;->getHandler()Landroid/os/Handler;

    move-result-object v2

    const/4 v3, 0x4

    invoke-virtual {v1, v2, v3}, Lrexsee/barcode/CameraPreviewCallback;->setHandler(Landroid/os/Handler;I)V

    .line 94
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-boolean v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mUseOneShotPreviewCallback:Z

    if-eqz v1, :cond_1

    .line 95
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v2, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v2, v2, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    invoke-virtual {v1, v2}, Landroid/hardware/Camera;->setOneShotPreviewCallback(Landroid/hardware/Camera$PreviewCallback;)V

    .line 99
    :goto_0
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mAutoFocusCallback:Lrexsee/barcode/CameraAutoFocusCallback;

    const/4 v2, 0x0

    invoke-virtual {v1, p0, v2}, Lrexsee/barcode/CameraAutoFocusCallback;->setHandler(Landroid/os/Handler;I)V

    .line 100
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v2, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v2, v2, Lrexsee/barcode/BarcodeCaptureDialog;->mAutoFocusCallback:Lrexsee/barcode/CameraAutoFocusCallback;

    invoke-virtual {v1, v2}, Landroid/hardware/Camera;->autoFocus(Landroid/hardware/Camera$AutoFocusCallback;)V

    .line 101
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mViewfinderView:Lrexsee/barcode/ViewfinderView;

    invoke-virtual {v1}, Lrexsee/barcode/ViewfinderView;->drawViewfinder()V

    .line 106
    :cond_0
    :goto_1
    return-void

    .line 97
    :cond_1
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v2, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v2, v2, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    invoke-virtual {v1, v2}, Landroid/hardware/Camera;->setPreviewCallback(Landroid/hardware/Camera$PreviewCallback;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 103
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 104
    .local v0, "e":Ljava/lang/Exception;
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    invoke-virtual {v1}, Lrexsee/barcode/BarcodeCaptureDialog;->getContext()Landroid/content/Context;

    move-result-object v1

    invoke-virtual {v0}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v2

    const/4 v3, 0x1

    invoke-static {v1, v2, v3}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v1

    invoke-virtual {v1}, Landroid/widget/Toast;->show()V

    goto :goto_1
.end method


# virtual methods
.method public handleMessage(Landroid/os/Message;)V
    .locals 6
    .param p1, "message"    # Landroid/os/Message;

    .prologue
    .line 38
    :try_start_0
    iget v3, p1, Landroid/os/Message;->what:I

    packed-switch v3, :pswitch_data_0

    .line 67
    :cond_0
    :goto_0
    return-void

    .line 40
    :pswitch_0
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    sget-object v4, Lrexsee/barcode/CaptureHandler$State;->PREVIEW:Lrexsee/barcode/CaptureHandler$State;

    if-ne v3, v4, :cond_0

    .line 41
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mAutoFocusCallback:Lrexsee/barcode/CameraAutoFocusCallback;

    const/4 v4, 0x0

    invoke-virtual {v3, p0, v4}, Lrexsee/barcode/CameraAutoFocusCallback;->setHandler(Landroid/os/Handler;I)V

    .line 42
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v4, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v4, v4, Lrexsee/barcode/BarcodeCaptureDialog;->mAutoFocusCallback:Lrexsee/barcode/CameraAutoFocusCallback;

    invoke-virtual {v3, v4}, Landroid/hardware/Camera;->autoFocus(Landroid/hardware/Camera$AutoFocusCallback;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 64
    :catch_0
    move-exception v3

    move-object v2, v3

    .line 65
    .local v2, "e":Ljava/lang/Exception;
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    invoke-virtual {v3}, Lrexsee/barcode/BarcodeCaptureDialog;->getContext()Landroid/content/Context;

    move-result-object v3

    invoke-virtual {v2}, Ljava/lang/Exception;->getLocalizedMessage()Ljava/lang/String;

    move-result-object v4

    const/4 v5, 0x1

    invoke-static {v3, v4, v5}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v3

    invoke-virtual {v3}, Landroid/widget/Toast;->show()V

    goto :goto_0

    .line 46
    .end local v2    # "e":Ljava/lang/Exception;
    :pswitch_1
    :try_start_1
    invoke-direct {p0}, Lrexsee/barcode/CaptureHandler;->restartPreviewAndDecode()V

    goto :goto_0

    .line 49
    :pswitch_2
    sget-object v3, Lrexsee/barcode/CaptureHandler$State;->SUCCESS:Lrexsee/barcode/CaptureHandler$State;

    iput-object v3, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    .line 50
    invoke-virtual {p1}, Landroid/os/Message;->getData()Landroid/os/Bundle;

    move-result-object v1

    .line 51
    .local v1, "bundle":Landroid/os/Bundle;
    if-nez v1, :cond_1

    const/4 v3, 0x0

    move-object v0, v3

    .line 52
    .local v0, "barcode":Landroid/graphics/Bitmap;
    :goto_1
    iget-object v4, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v3, Lcom/google/zxing/Result;

    invoke-virtual {v4, v3, v0}, Lrexsee/barcode/BarcodeCaptureDialog;->decode(Lcom/google/zxing/Result;Landroid/graphics/Bitmap;)V

    goto :goto_0

    .line 51
    .end local v0    # "barcode":Landroid/graphics/Bitmap;
    :cond_1
    const-string v3, "barcode_bitmap"

    invoke-virtual {v1, v3}, Landroid/os/Bundle;->getParcelable(Ljava/lang/String;)Landroid/os/Parcelable;

    move-result-object v3

    check-cast v3, Landroid/graphics/Bitmap;

    move-object v0, v3

    goto :goto_1

    .line 55
    .end local v1    # "bundle":Landroid/os/Bundle;
    :pswitch_3
    sget-object v3, Lrexsee/barcode/CaptureHandler$State;->PREVIEW:Lrexsee/barcode/CaptureHandler$State;

    iput-object v3, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    .line 56
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    iget-object v4, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    invoke-virtual {v4}, Lrexsee/barcode/DecodeThread;->getHandler()Landroid/os/Handler;

    move-result-object v4

    const/4 v5, 0x4

    invoke-virtual {v3, v4, v5}, Lrexsee/barcode/CameraPreviewCallback;->setHandler(Landroid/os/Handler;I)V

    .line 57
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-boolean v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mUseOneShotPreviewCallback:Z

    if-eqz v3, :cond_2

    .line 58
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v4, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v4, v4, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    invoke-virtual {v3, v4}, Landroid/hardware/Camera;->setOneShotPreviewCallback(Landroid/hardware/Camera$PreviewCallback;)V

    goto :goto_0

    .line 60
    :cond_2
    iget-object v3, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v3, v3, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    iget-object v4, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v4, v4, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    invoke-virtual {v3, v4}, Landroid/hardware/Camera;->setPreviewCallback(Landroid/hardware/Camera$PreviewCallback;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto/16 :goto_0

    .line 38
    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
    .end packed-switch
.end method

.method public quitSynchronously()V
    .locals 4

    .prologue
    const/4 v3, 0x0

    const/4 v2, 0x0

    .line 69
    sget-object v1, Lrexsee/barcode/CaptureHandler$State;->DONE:Lrexsee/barcode/CaptureHandler$State;

    iput-object v1, p0, Lrexsee/barcode/CaptureHandler;->state:Lrexsee/barcode/CaptureHandler$State;

    .line 70
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    if-eqz v1, :cond_1

    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-boolean v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewing:Z

    if-eqz v1, :cond_1

    .line 71
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-boolean v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mUseOneShotPreviewCallback:Z

    if-nez v1, :cond_0

    .line 72
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v1, v3}, Landroid/hardware/Camera;->setPreviewCallback(Landroid/hardware/Camera$PreviewCallback;)V

    .line 74
    :cond_0
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mCamera:Landroid/hardware/Camera;

    invoke-virtual {v1}, Landroid/hardware/Camera;->stopPreview()V

    .line 75
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewCallback:Lrexsee/barcode/CameraPreviewCallback;

    invoke-virtual {v1, v3, v2}, Lrexsee/barcode/CameraPreviewCallback;->setHandler(Landroid/os/Handler;I)V

    .line 76
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iget-object v1, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mAutoFocusCallback:Lrexsee/barcode/CameraAutoFocusCallback;

    invoke-virtual {v1, v3, v2}, Lrexsee/barcode/CameraAutoFocusCallback;->setHandler(Landroid/os/Handler;I)V

    .line 77
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->mDialog:Lrexsee/barcode/BarcodeCaptureDialog;

    iput-boolean v2, v1, Lrexsee/barcode/BarcodeCaptureDialog;->mPreviewing:Z

    .line 79
    :cond_1
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    invoke-virtual {v1}, Lrexsee/barcode/DecodeThread;->getHandler()Landroid/os/Handler;

    move-result-object v1

    const/4 v2, 0x5

    invoke-static {v1, v2}, Landroid/os/Message;->obtain(Landroid/os/Handler;I)Landroid/os/Message;

    move-result-object v0

    .line 80
    .local v0, "quit":Landroid/os/Message;
    invoke-virtual {v0}, Landroid/os/Message;->sendToTarget()V

    .line 82
    :try_start_0
    iget-object v1, p0, Lrexsee/barcode/CaptureHandler;->decodeThread:Lrexsee/barcode/DecodeThread;

    invoke-virtual {v1}, Lrexsee/barcode/DecodeThread;->join()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 86
    :goto_0
    const/4 v1, 0x2

    invoke-virtual {p0, v1}, Lrexsee/barcode/CaptureHandler;->removeMessages(I)V

    .line 87
    const/4 v1, 0x3

    invoke-virtual {p0, v1}, Lrexsee/barcode/CaptureHandler;->removeMessages(I)V

    .line 88
    return-void

    .line 83
    :catch_0
    move-exception v1

    goto :goto_0
.end method
